<!DOCTYPE html>
<html>
<head>
<include file="Include:meta" />
<title>物资库-目的地运营集团数据管理平台</title>
<include file="Include:style" />
<style>
	.folder span{ display: inline-block; margin: 0 40px 0 1px; }
	em{ font-style: normal; }
</style>
</head>
<body>
<include file="Include:header" />
<include file="Include:left" />
<div id="main">
	<div class="crumbs">
		<div class="crumbs-text">行政 > 物资库</div>
		<div class="right">
			<div class="input-group left w200">
		    	<input type="text" id="keyword" value="{$keyword}" class="form-control" placeholder="按物资编号/名称搜索" autocomplete="off">
	    		<span class="input-group-btn">
	        		<button class="btn found_btn" type="button">搜索</button>
		    	</span>
		    </div>
			<if condition="is_permission('WZ',NULL,1)">
			<a href="__APP__/Administration/material_add" class="btn left ml5">添加物资</a>
			</if>
		</div>
	</div>
	<div id="content">
		<div class="filter">
			<div>
				<div class="filter-title">类型</div>
				<ul class="filter-order">
					<li <if condition="$type eq -10">class="current"</if>>
						<a href="__APP__/Administration/material/type/-10">全部</a>
					</li>
					<li <if condition="$type eq 1">class="current"</if>>
						<a href="__APP__/Administration/material/type/1">礼品</a>
					</li>
					<li <if condition="$type eq 2">class="current"</if>>
						<a href="__APP__/Administration/material/type/2">办公用品</a>
					</li>
				</ul>
			</div>
		</div>
		<div class="table-scrollx">
			<table class="table table-bordered table-hover">
				<tr class="table-header fixed-table-header">
					<td width="">物资编号</td>
					<td width="">物资名称</td>
					<td width="">规格</td>
					<td width="">品牌</td>
					<td width="">存量</td>
					<if condition="is_permission('WZ',NULL,1)">
					<td width="">管理<a href="__APP__/Administration/material_change_all" data-toggle="tooltip" data-placement="left" title="" class="edit ml5" data-original-title="全部流水" target="_blank"><i class="glyphicon glyphicon-list-alt"></i></a></td>
					</if>
				</tr>
				<if condition="$result eq NULL">
				<tr><td class="Text_c" <if condition="is_permission('WZ',NULL,1)">colspan="6"<else/>colspan="5"</if>>暂无相关数据</td></tr>
				</if>
				<foreach name="result" item="vo">
					<tr>
						<td><a href="__APP__/Administration/material_detail/id/{$vo['id']}">{$vo['number']}</a></td>
						<td>{$vo['name']}</td>
						<td>{$vo['norms']}</td>
						<td>{$vo['brand']}</td>
						<td><a href="__APP__/Administration/material_change/id/{$vo['id']}" target="_blank">{$vo['sy']}</a></td>
						<if condition="is_permission('WZ',NULL,1)">
						<td>
							<a href="javascript:;" mid="{$vo['id']}" price="{$vo['price']+0}" data-toggle="tooltip" data-placement="left" title="入库" class="in mr5"><i class="glyphicon glyphicon-log-in"></i></a>
							<if condition="$vo['rk'] neq NULL">
							<a href="javascript:;" mid="{$vo['id']}" price="{$vo['price']+0}" sy="{$vo['sy']}" data-toggle="tooltip" data-placement="left" title="出库" class="out mr5"><i class="glyphicon glyphicon-log-out"></i></a>
							</if>
							<a href="__APP__/Administration/material_edit/id/{$vo['id']}" data-toggle="tooltip" data-placement="left" title="" class="edit mr5" data-original-title="编辑"><i class="glyphicon glyphicon-edit"></i></a>
							<if condition="$vo['audit'] eq 1">
								<a href="javascript:;" mid="{$vo['id']}" action="delete" data-toggle="tooltip" data-placement="left" title="删除" class="delete"><i class="glyphicon glyphicon-trash"></i></a>
							</if>
						</td>
						</if>
					</tr>
				</foreach>
			</table>
		</div>
		<div class="pages">{$page}</div>
	</div>
</div>
<!--弹框-->
<div class="modal fade" id="in-modal">
	<div class="modal-dialog w600">
		<div class="modal-content">
			<div class="modal-header">
				<h4>入库</h4>
				<i class="fa fa-times" aria-hidden="true" data-dismiss="modal"></i>
			</div>
			<form class="in_form1" action="__APP__/Administration/material_add" method="post" enctype="multipart/form-data">
			<input type="hidden" name="action" value="add">
			<input type="hidden" name="types" value="1">
			<div class="modal-body" style="line-height:30px;">
				<table class="table table-bordered">
					<tr>
						<td class="text-right" width="74"><strong><span class="asterisk">*</span>事业部</strong></td>
						<td>
							<span class="checkbox-item in_radio">
								<label class="radio-inline"><input type="radio" name="business_unit" value="目的地" autocomplete="off">目的地</label>
								<label class="radio-inline"><input type="radio" name="business_unit" value="旅投" autocomplete="off">旅投</label>
								<label class="radio-inline"><input type="radio" name="business_unit" value="旅发" autocomplete="off">旅发</label>
								<label class="radio-inline"><input type="radio" name="business_unit" value="景翼" autocomplete="off">景翼</label>
								<span class="error-item">必填项</span>
							</span>
							<span class="error-item">必填项</span>
						</td>
					</tr>
					<tr>
						<td class="text-right"><strong><span class="asterisk">*</span>来源</strong></td>
						<td>
							<input type="text" name="manufacturer" class="form-control required-text w150" autocomplete="off">
							<span class="error-item">必填项</span>
						</td>
					</tr>
					<tr>
						<td class="text-right"><strong><span class="asterisk">*</span>数量</strong></td>
						<td>
							<input type="text" name="nums1" class="form-control required-text w150" autocomplete="off">
							<span class="error-item">必填项</span>
							<span class="error-item">必须是大于0的整数</span>
						</td>
					</tr>
					<tr>
						<td class="text-right"><strong><span class="asterisk">*</span>单价(元)</strong></td>
						<td>
							<input type="text" name="prices" class="form-control required-text w150" autocomplete="off">
							<span class="error-item">必填项</span>
							<span class="error-item">必须是大于0且可保留两位小数的数字</span>
						</td>
					</tr>
				</table>
			</div>
			<div class="modal-footer">
				<p class="Text_c1" style="color: #a94442;"></p>
				<button type="button" class="btn btn-affirm1">确认</button><button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
			</div>
			</form>
		</div>
	</div>
</div>
<!--弹框-->
<div class="modal fade" id="out-modal">
	<div class="modal-dialog w600">
		<div class="modal-content">
			<div class="modal-header">
				<h4>出库</h4>
				<i class="fa fa-times" aria-hidden="true" data-dismiss="modal"></i>
			</div>
			<form class="in_form2" action="__APP__/Administration/material_add" method="post" enctype="multipart/form-data">
			<input type="hidden" name="action" value="add">
			<input type="hidden" name="types" value="2">
			<div class="modal-body" style="line-height:30px;">
				<table class="table table-bordered">
					<tr>
						<td class="text-right" width="74"><strong><span class="asterisk">*</span>事业部</strong></td>
						<td>
							<span class="checkbox-item out_radio">
								<label class="radio-inline"><input type="radio" name="business_unit" value="目的地" autocomplete="off">目的地</label>
								<label class="radio-inline"><input type="radio" name="business_unit" value="旅投" autocomplete="off">旅投</label>
								<label class="radio-inline"><input type="radio" name="business_unit" value="旅发" autocomplete="off">旅发</label>
								<label class="radio-inline"><input type="radio" name="business_unit" value="景翼" autocomplete="off">景翼</label>
								<span class="error-item">必填项</span>
							</span>
							<span class="error-item">必填项</span>
						</td>
					</tr>
					<tr>
						<td class="text-right"><strong><span class="asterisk">*</span>数量</strong></td>
						<td>
							<input type="text" name="nums" class="form-control required-text w150" autocomplete="off">
							<span class="error-item">必填项</span>
							<span class="error-item">必须是大于0的整数</span>
							<span class="input-prompt ml10" style="color:#999"><i class="glyphicon glyphicon-exclamation-sign mr5"></i>库存剩余数<em></em></span>
						</td>
					</tr>
					<tr>
						<td class="text-right"><strong><span class="asterisk">*</span>单价(元)</strong></td>
						<td>
							<input type="text" name="pricess" class="form-control required-text w150" autocomplete="off">
							<span class="error-item">必填项</span>
							<span class="error-item">必须是大于0且可保留两位小数的数字</span>
						</td>
					</tr>
					<tr>
						<td class="text-right"><strong><span class="asterisk">*</span>领用人</strong></td>
						<td>
							<select name="user" class="form-control required-selted w150" autocomplete="off">
								<option value="-10">请选择</option>
								<foreach name="user" item="uo">
								<option value="{$uo['id']}">{$uo['username']}</option>
								</foreach>
							</select>
							<span class="error-item">必填项</span>
						</td>
					</tr>
					<tr>
						<td class="text-right"><strong><span class="asterisk">*</span>用途</strong></td>
						<td>
							<input type="text" name="purpose" class="form-control required-text w300" autocomplete="off">
							<span class="error-item">必填项</span>
						</td>
					</tr>
				</table>
			</div>
			<div class="modal-footer">
				<p class="Text_c" style="color: #a94442;"></p>
				<button type="button" class="btn btn-affirm2">确认</button><button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
			</div>
			</form>
		</div>
	</div>
</div>
<include file="Include:javascript" />
<script type="text/javascript">
$(function(){
	//搜索
	$(".found_btn").keywordSearch("__APP__/Administration/material/keyword/$keyword");
	//删除
	$(".delete").ajaxModal({"title_text":"确认提示框","body_text":"您确定要删除吗？","url":"__APP__/Administration/material_ajax","data":{"id":"mid","action":"action"}});
	$('.in').click(function(){
		$('.required-text').val('');
		$('.radio-inline input').prop('checked',false);
		$('.error-item').hide();
		var mid = $(this).attr('mid'),
			price = $(this).attr('price');
		$('#in-modal').modal();
		$('.btn-affirm1').attr('mid',mid);
		$('#in-modal').modal().find("[name='prices']").val(price);
	})
	$('.out').click(function(){
		$('.required-text').val('');
		$('.radio-inline input').prop('checked',false);
		$('.required-selted').val('-10').select2();
		$('.error-item').hide();
		var mid = $(this).attr('mid'),
			price = $(this).attr('price'),
			sy = $(this).attr('sy');
		$('#out-modal').modal();
		$('.btn-affirm2').attr('mid',mid);
		$('#out-modal').modal().find("[name='pricess']").val(price);
		$('#out-modal .modal-footer p.Text_c').html('');
		$('.input-prompt em').html(sy);
	})
	$('.btn-affirm1').click(function(){
		var tag = true;
		$('#in-modal .required-text').each(function(){
			var val = $(this).val();
			if(val==''){
				$(this).next('.error-item').show();
				tag = false;
			}
		})
		if($('.in_radio').find('input:checked').length<1){
			$('.in_radio').find(".error-item").show();
			tag = false;
		}
		var size = $("[name='nums1']").val();
		if(!/^\+?[1-9]\d*$/.test(size) && size!=""){
			$("[name='nums1']").nextAll(".error-item").eq(1).show();
			tag = false;
		}
		var money = $("[name='prices']").val();
		if(!/^(?!0$|0\.00|0\d+$)([1-9]?\d+(\.\d{1,2})?)$/.test(money) && money!=""){
			$("[name='prices']").nextAll(".error-item").eq(1).show();
			tag = false;
		}
		if(tag){
			var mid = $(this).attr('mid'),
				modal = $("#in-modal");
			$.ajax({
				type:"POST",
				async:false,
				dataType:"json",
				data:$('.in_form1').serialize()+"&id="+mid,
				url:"__APP__/Administration/appliance_list_ajax",
				success:function(data){
					if(data.status==1){
						modal.hide();
						success_pop(data.status,data.msg);
					}else{
						$('.Text_c1').html(data.msg);
					}
				}
			})
		}
	})
	$('.btn-affirm2').click(function(){
		var tag = true;
		$('#out-modal .required-text').each(function(){
			var val = $(this).val();
			if(val==''){
				$(this).next('.error-item').show();
				tag = false;
			}
		})
		if($('#out-modal select').val()==-10){
			$('#out-modal select').nextAll('.error-item').show();
			tag = false;
		}
		if($('.out_radio').find('input:checked').length<1){
			$('.out_radio').find(".error-item").show();
			tag = false;
		}
		var size = $("[name='nums']").val();
		if(!/^\+?[1-9]\d*$/.test(size) && size!=""){
			$("[name='nums']").nextAll(".error-item").eq(1).show();
			tag = false;
		}
		var money = $("[name='pricess']").val();
		if(!/^(?!0$|0\.00|0\d+$)([1-9]?\d+(\.\d{1,2})?)$/.test(money) && money!=""){
			$("[name='pricess']").nextAll(".error-item").eq(1).show();
			tag = false;
		}
		if(tag){
			var mid = $(this).attr('mid'),
				modal = $("#out-modal");
			$.ajax({
				type:"POST",
				async:false,
				dataType:"json",
				data:$('.in_form2').serialize()+"&id="+mid,
				url:"__APP__/Administration/appliance_list_ajax",
				success:function(data){
					if(data.status==1){
						modal.hide();
						success_pop(data.status,data.msg);
					}else{
						$('.Text_c').html(data.msg);
					}
				}
			})
		}
	})
	$('.required-text').focus(function(){
		$(this).nextAll('.error-item').hide();
	})
	$('label').click(function(){
		$(this).parent().find(".error-item").hide();
	})
	$('#out-modal select').change(function(){
		$(this).nextAll('.error-item').hide();
	})
});
</script>
</body>
</html>